-
-
Notifications
You must be signed in to change notification settings - Fork 246
feat: Integrate bulk token screening into transaction simulation flow within runAfterSimulateHook #6617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/add-bulk-token-screening
Are you sure you want to change the base?
feat: Integrate bulk token screening into transaction simulation flow within runAfterSimulateHook #6617
Conversation
…taMask/core into feat/add-token-screening-tx-controller
…d TransactionController
…redundant logging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two solutions that would not require coupling our code into the transactions controller. We can:
- just listen for transaction controller state changes within the phishing controller, and whenever there are state changes in a transaction simulation data, we fire the bulk scanning method. This should be seamless as all controllers already emit state change events.
- add the logic to the actual (afterSimulate)[https://github.com/MetaMask/metamask-extension/blob/main/app/scripts/controller-init/confirmations/transaction-controller-init.ts#L131] hook on the transaction controller initialization. The goal of the hooks architecture is for us to be able to add non transaction related logic to be run in different steps of the transaction lifecycle but at the same time keep the codebase decoupled and the domain ownership easily identified.
I would personaly go with option 1 that I highlighted above, as it allows us to adopt the solution on mobile without any changes (despite the UI ones to display the trust signals).
… state subscription in PhishingController
Explanation
This PR integrates the bulk token screening functionality from the
PhishingController
into the TransactionController's transaction simulation workflow. When a transaction simulation completes with received tokens, those tokens are scanned in a fire and forget method.Changes introduced
#bulkScanReceivedTokens
method that scans tokens received during transaction simulationPhishingController:bulkScanTokens
to the TransactionController's allowed actions#afterSimulate
workflow as a fire and forgetScreenshot showcasing the
tokenScanCache
is implemented as expectedThis is grabbed via the extension console using await stateHooks.getPersistedState() after triggering a swap in uniswap. You will notice i was doing a swap for USDC which is the only token address stored in the cache.
References
Checklist